//////////////////////////////////////////////////////////////////////////
//
// 2005 by Stefan Hahne (Stefan.Hahne@gmx.de).
// 
// Parts of this program may have a different copyright.
// This library is free software; you can redistribute it and/or modify
// it.
//
//////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_PARFILE_H
#define INCLUDED_PARFILE_H



class ParFile
{
public:
  ParFile(const char *filename);
  ~ParFile();

// NOTE: Weil GetValue() statischen Speicher fuer den Rueckgabewert verwendet,
//       sollten nicht mehrere Aufrufe gleichzeitig als Argument fuer eine
//       andere Methode verwendet werden, weil sonst je nach Auswertereihenfolge
//       immer nur das letzte Ergebnis verwendet wird!!

  char *GetValue(const char *section, const char *descriptor);
  char *CutSpace(char *value);


protected:
  bool Load(const char *filename);
  char *SearchSection(const char *section);
  char *SearchDescriptor(const char *descriptor, char *sectionstart);

private:
  ParFile();
  ParFile(const ParFile& copyMe);
  ParFile& operator=(const ParFile& rhs);

private:
  enum { PAR_FILENAME_MAX=100 };
  char  m_filename[PAR_FILENAME_MAX];
  bool  m_fLoaded;
  char *m_pData;
  unsigned long m_size;

  enum { PAR_DESCRIPTOR_VALUE_MAX=256 };
  char m_descvalue[PAR_DESCRIPTOR_VALUE_MAX];

  // some useful constans
  static const char PAR_SECTION_DESC_START;
  static const char PAR_SECTION_DESC_END;
  static const char PAR_COMMENT;
  static const char PAR_DESCRIPTOR_SEP;
  static const char PAR_EOLN;
  static const char PAR_QUOTES;
};


#endif /*!INCLUDED_PARFILE_H*/


